package com.hxht.cmp.controller;

import com.hxht.cmp.common.enums.ResultCode;
import com.hxht.cmp.common.result.ResultResponse;
import com.hxht.cmp.pojo.LogInfoRequirement;
import com.hxht.cmp.service.LogInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/log")
public class LogInfoController {

    @Autowired
    private LogInfoService logInfoService;

    @RequestMapping("/selectLogInfo")
    @ResponseBody
    public ResultResponse selectLogInfo(LogInfoRequirement logInfoRequirement) {
        if (ObjectUtils.isEmpty(logInfoRequirement)) {
            ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        if (logInfoRequirement.getPage() <1 || logInfoRequirement.getPageSize() < 1 || ObjectUtils.isEmpty(logInfoRequirement.getStarts())){
            ResultResponse.failed();
        }
        Map<String, Object> logMap=  logInfoService.selectLogInfo(logInfoRequirement);
        return ResultResponse.success(logMap);
    }
}
